package com.vegetable.modules.entity.bank.vo;

import cn.afterturn.easypoi.excel.annotation.Excel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;

import java.math.BigDecimal;
import java.util.Date;

@Data
public class RCBCTran {
    /**
     * 交易日期
     */
    @Excel(name ="交易日期", fixedIndex = 1, format = "yyyy-MM-dd HH:mm")
    private Date tranDate;

    @Excel(name ="交易金额", fixedIndex = 2)
    private String tradingAmountStr;

    @ApiModelProperty("交易金额")
    private BigDecimal tradingAmount;

    @Excel(name = "交易类型", fixedIndex = 3)
    private String tradingType;

    @Excel(name = "钞汇标志", fixedIndex = 4)
    private String cashExchange;

    @Excel(name ="账户余额", fixedIndex = 5)
    private String balanceAmountStr;

    @ApiModelProperty(name ="账户余额")
    private BigDecimal balanceAmount;

    public BigDecimal getBalanceAmount() {
        if (balanceAmountStr == null) return null;
        // 清理货币符号和千位分隔符（保留小数点和负号）
        String cleanValue = balanceAmountStr
                .replaceAll("[^\\d.-]", "")  // 移除非数字、非小数点、非负号
                .replaceAll("(?<=\\d)-(?=\\d)", ""); // 移除数字间的短横（如千位分隔符）

        // 处理空字符串
        if (cleanValue.isEmpty()) return null;
        return new BigDecimal(cleanValue);
    }

    public BigDecimal getTradingAmount() {
        if (tradingAmountStr == null) return null;
        // 清理货币符号和千位分隔符（保留小数点和负号）
        String cleanValue = tradingAmountStr
                .replaceAll("[^\\d.-]", "")  // 移除非数字、非小数点、非负号
                .replaceAll("(?<=\\d)-(?=\\d)", ""); // 移除数字间的短横（如千位分隔符）

        // 处理空字符串
        if (cleanValue.isEmpty()) return null;
        return new BigDecimal(cleanValue);
    }

    @Excel(name = "对方账号", fixedIndex = 6)
    private String bankNo;

    @Excel(name = "对方户名", fixedIndex = 7)
    private String counterparty;

    @Excel(name = "交易渠道", fixedIndex = 8)
    private String bankName;

    @Excel(name = "受理机构", fixedIndex = 9)
    private String purpose;

    @Excel(name = "摘要", fixedIndex = 10)
    private String summary;
}
